package com.qcby.chatservice.common.enums;

import cn.hutool.core.util.StrUtil;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 套接字处理类型
 * socket操作类型
 *
 * @author cong.zhen
 * @date 2023/01/04
 */
@Getter
@AllArgsConstructor
public enum SocketHandleType {
    LOGIN("1","登录","singleChatHandle"),
    OPERATION_GROUP("2","操作群组","singleChatHandle"),
    P2P("3","点对点消息","singleChatHandle"),
    GROUP_MSG("4","群聊消息","singleChatHandle"),
    QUIT_GROUP("5","退出群组","singleChatHandle"),
    FILE_P2P("6","发送个人文件","singleChatHandle"),
    FILE_GROUP("7","发送群组文件","singleChatHandle"),
    PUSH_MSG("8","发送推送消息","singleChatHandle"),
    RETURN_DEAL("10","返回消息处理","singleChatHandle"),
    WITHDRAW("12","消息撤销处理","singleChatHandle"),
    READ_MESSAGE("13","已读消息接收","singleChatHandle"),
    OFFLINE_MESSAGE("14","获取离线消息","singleChatHandle"),
    SEND_OFFLINE_MESSAGE("15","离线消息推送","singleChatHandle"),
    SEND_REPEAT_LOGIN_MESSAGE("16","其他客服端登录，强制退出","singleChatHandle"),
    DING_MESSAGE("21","发送钉操作","singleChatHandle"),
    DING_READ("22","钉已读","singleChatHandle"),
    FORBIDDEN_SPEECH("27", "禁言功能","singleChatHandle"),
    COMMON_NOTICE_SEND("31", "websocket通知客户端","singleChatHandle"),
    CONNECT_STATISTICS("90","连接数统计","singleChatHandle"),
    HEART("99","心跳","singleChatHandle");
    /**
     * 编码
     */
    private String code;
    /**
     * 描述
     */
    private String description;

    private String handleType;

    public static String getHandleByCode(String code){
        if(StrUtil.isBlank(code)){
            return null;
        }
        for (SocketHandleType value : SocketHandleType.values()) {
            if(value.getCode().equals(code)){
                return value.getHandleType();
            }
        }
        return null;
    }
}
